package com.yzxb.messystem.mapper;

import com.yzxb.messystem.entity.WorkOrder;
import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 工单Mapper接口
 * 使用MyBatis提供CRUD操作
 */
@Mapper
public interface WorkOrderMapper {

    // 基础CRUD操作
    int insert(WorkOrder workOrder);
    
    int updateById(WorkOrder workOrder);
    
    int deleteById(Long id);
    
    WorkOrder selectById(Long id);
    
    List<WorkOrder> selectList(WorkOrder workOrder);

    // 根据工单编码查询工单
    WorkOrder findByOrderCode(String orderCode);
    
    // 根据状态查询工单
    List<WorkOrder> findByStatus(WorkOrder.OrderStatus status);
    
    // 根据生产线查询工单
    List<WorkOrder> findByProductionLine(String productionLine);
    
    // 根据产品ID查询工单
    List<WorkOrder> findByProductId(Long productId);
    
    // 根据计划开始日期范围查询工单
    List<WorkOrder> findByPlannedStartDateBetween(LocalDateTime startDate, LocalDateTime endDate);
    
    // 检查工单编码是否存在
    int existsByOrderCode(String orderCode);
    
    // 更新工单数量信息
    int updateWorkOrderQuantities(Long id, Integer completedQuantity, Integer rejectedQuantity);
}